package com.yaohe.common;



public class ActiveCoupon {
	public Coupon staticInfo;
	private int couponRemaining;

	public ActiveCoupon(Coupon c) {
		this.staticInfo = c;
		
		couponRemaining = c.amount;
		
	}

	public int getCouponRemaining() {
		return couponRemaining;
	}

	public synchronized void setCouponRemaining(int couponRemaining) {
		this.couponRemaining = couponRemaining;
	}
	
	public synchronized boolean increaseCouponRemaining(){
		if (couponRemaining < staticInfo.amount){
			couponRemaining ++;
			return true;
		}
		else return false;
	}
	
	public synchronized boolean decreaseCouponRemaining(){
		if (couponRemaining > 0){
			couponRemaining --;
			return true;
		}
		else return false;
	}
	public int hashCode() {
		return this.staticInfo.hashCode();
	}

	public boolean equals(Object o) {
		if (o instanceof ActiveCoupon) {
			if (this.staticInfo.id.equals(((ActiveCoupon)o).staticInfo.id))
				return true;

		}
		return false;
	}

	

}

